package edu.fdzc.learn.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import edu.fdzc.learn.entity.Exam;

import edu.fdzc.learn.entity.vo.ExamVO;
import edu.fdzc.learn.mapper.ExamMapper;
import edu.fdzc.learn.service.ExamService;
import org.springframework.stereotype.Service;



@Service
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService {

    @Override
    public ExamVO getExamDetail(Long examId) {
        // 1. 根据ID查询考试实体
        Exam exam = getExamById(examId);
        if (exam == null) {
            throw new RuntimeException("考试不存在");
        }

        ExamVO vo = new ExamVO();
        vo.setId(exam.getId());
        vo.setCourseId(exam.getCourseId());
        vo.setTitle(exam.getTitle());
        vo.setCreatedAt(exam.getCreatedAt());

        vo.setCourseName("高数");

        return vo;
    }

    @Override
    public Exam getExamById(Long examId) {
        return baseMapper.getExamById(examId);
    }
}